Skip to content

Commit

Permalink
Implementing augmentation indicator as an annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
barancev committed Apr 9, 2014
1 parent f595c50 commit cbac104
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
30 changes: 30 additions & 0 deletions java/client/src/org/openqa/selenium/remote/Augmentable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright 2014 Selenium committers
Copyright 2014 Software Freedom Conservancy
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package org.openqa.selenium.remote;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Indicates that a class can be processed by {@link org.openqa.selenium.remote.Augmenter}.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Augmentable { }
2 changes: 1 addition & 1 deletion java/client/src/org/openqa/selenium/remote/Augmenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected <X> X create(RemoteWebDriver driver,

@Override
protected RemoteWebDriver extractRemoteWebDriver(WebDriver driver) {
if (driver.getClass() == RemoteWebDriver.class
if (driver.getClass().isAnnotationPresent(Augmentable.class)
|| driver.getClass().getName().startsWith("org.openqa.selenium.remote.RemoteWebDriver$$EnhancerByCGLIB"))
{
return (RemoteWebDriver) driver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
import java.util.logging.Level;
import java.util.logging.Logger;

@Augmentable
public class RemoteWebDriver implements WebDriver, JavascriptExecutor,
FindsById, FindsByClassName, FindsByLinkText, FindsByName,
FindsByCssSelector, FindsByTagName, FindsByXPath,
Expand Down

0 comments on commit cbac104

Please sign in to comment.